package c.c.a;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.provider.Settings.Secure;
import android.util.Log;
import java.math.BigInteger;
import java.security.SecureRandom;
import org.json.JSONObject;

public class j extends b2 {
    public final Context e;

    public j(Context context) {
        super(false, false);
        this.e = context;
    }

    public boolean b(JSONObject jSONObject) {
        Object string;
        try {
            string = Secure.getString(this.e.getContentResolver(), "android_id");
        } catch (Exception e) {
            Log.e("TeaLog", "", e);
            string = null;
        }
        String str = "openudid";
        if (!c.g(string) || "9774d56d682e549c".equals(string)) {
            SharedPreferences sharedPreferences = this.e.getSharedPreferences("snssdk_openudid", 0);
            String string2 = sharedPreferences.getString(str, null);
            if (!c.g(string2)) {
                string2 = new BigInteger(64, new SecureRandom()).toString(16);
                if (string2.charAt(0) == '-') {
                    string2 = string2.substring(1);
                }
                int length = 13 - string2.length();
                if (length > 0) {
                    StringBuilder stringBuilder = new StringBuilder();
                    while (length > 0) {
                        stringBuilder.append('F');
                        length--;
                    }
                    stringBuilder.append(string2);
                    string2 = stringBuilder.toString();
                }
                try {
                    string2 = a("openudid.dat", string2);
                } catch (Exception unused) {
                }
                Editor edit = sharedPreferences.edit();
                edit.putString(str, string2);
                edit.apply();
            }
            string = string2;
        }
        jSONObject.put(str, string);
        return true;
    }
}
